/*站点*/
var siteId = $("input[name='siteId']");
/**
 * 加入购物车并收藏页面---超级链接
 */
var cart_url_one_day = $("input[name='cart_url_one_day']");
var cart_url_two_day = $("input[name='cart_url_two_day']");
var cart_url_three_day = $("input[name='cart_url_three_day']");
var cart_url_four_day = $("input[name='cart_url_four_day']");
var cart_url_five_day = $("input[name='cart_url_five_day']");
var cart_url_six_day = $("input[name='cart_url_six_day']");
var cart_url_seven_day = $("input[name='cart_url_seven_day']");
var cart_url_eight_day = $("input[name='cart_url_eight_day']");
var cart_url_nine_day = $("input[name='cart_url_nine_day']");
var cart_url_ten_day = $("input[name='cart_url_ten_day']");
/*超级链接--单笔手续费*/
var cart_url_charge = $("input[name='cart_url_charge']");
/*超级链接--总数量*/
var cart_url_day_sun = $("input[name='cart_url_day_sun']");
/*超级链接--总手续费*/
var cart_url_sun = $("input[name='cart_url_sun']");
/**
 * 加入购物车并收藏页面---搜索结果
 */
var cart_result_one_day = $("input[name='cart_result_one_day']");
var cart_result_two_day = $("input[name='cart_result_two_day']");
var cart_result_three_day = $("input[name='cart_result_three_day']");
var cart_result_four_day = $("input[name='cart_result_four_day']");
var cart_result_five_day = $("input[name='cart_result_five_day']");
var cart_result_six_day = $("input[name='cart_result_six_day']");
var cart_result_seven_day = $("input[name='cart_result_seven_day']");
var cart_result_eight_day = $("input[name='cart_result_eight_day']");
var cart_result_nine_day = $("input[name='cart_result_nine_day']");
var cart_result_ten_day = $("input[name='cart_result_ten_day']");
/*搜索结果--单笔手续费*/
var cart_result_charge = $("input[name='cart_result_charge']");
/*搜索结果--总数量*/
var cart_result_day_sun = $("input[name='cart_result_day_sun']");
/*搜索结果--总手续费*/
var cart_result_sun = $("input[name='cart_result_sun']");



//代购手续费总额
var procedureNum = $("input[name='procedureNum']");
//总支付金额
var payNum = $("input[name='payNum']");


$(function() {
	
	siteId.change(function(){
		sun();
	});
	cart_url_one_day.change(function() {
		sun();
	});
	cart_url_two_day.change(function() {
		sun();
	});
	cart_url_three_day.change(function() {
		sun();
	});
	cart_url_four_day.change(function() {
		sun();
	});
	cart_url_five_day.change(function() {
		sun();
	});
	cart_url_six_day.change(function() {
		sun();
	});
	cart_url_seven_day.change(function() {
		sun();
	});
	cart_url_eight_day.change(function() {
		sun();
	});
	cart_url_nine_day.change(function() {
		sun();
	});
	cart_url_ten_day.change(function() {
		sun();
	});
	
});

$(function() {
	
	siteId.change(function(){
		sun();
	});
	cart_result_one_day.change(function() {
		sun();
	});
	cart_result_two_day.change(function() {
		sun();
	});
	cart_result_three_day.change(function() {
		sun();
	});
	cart_result_four_day.change(function() {
		sun();
	});
	cart_result_five_day.change(function() {
		sun();
	});
	cart_result_six_day.change(function() {
		sun();
	});
	cart_result_seven_day.change(function() {
		sun();
	});
	cart_result_eight_day.change(function() {
		sun();
	});
	cart_result_nine_day.change(function() {
		sun();
	});
	cart_result_ten_day.change(function() {
		sun();
	});
	
});



function sun(){
	//超级链接-计算【总数量】【总手续费】
	cart_url_day_sun.val(sunDay(cart_url_one_day.val(),cart_url_two_day.val(), 
			cart_url_three_day.val(), cart_url_four_day.val(),
			cart_url_five_day.val(), cart_url_six_day.val(),
			cart_url_seven_day.val(), cart_url_eight_day.val(),
			cart_url_nine_day.val(), cart_url_ten_day.val()));
	cart_url_sun.val(sunHand(cart_url_day_sun.val(),cart_url_charge.val()));
	//搜索结果-计算【总数量】【总手续费】
	cart_result_day_sun.val(sunDay(cart_result_one_day.val(),cart_result_two_day.val(), 
			cart_result_three_day.val(), cart_result_four_day.val(),
			cart_result_five_day.val(), cart_result_six_day.val(),
			cart_result_seven_day.val(), cart_result_eight_day.val(),
			cart_result_nine_day.val(), cart_result_ten_day.val()));
	cart_result_sun.val(sunHand(cart_result_day_sun.val(),cart_result_charge.val()));
	
	//代购手续费总额
	procedureNum.val(proceNum(cart_url_sun.val(),cart_result_sun.val()));
	//总支付金额
	payNum.val(proceNum(cart_url_sun.val(),cart_result_sun.val()));
}




/*
 * 计算【总数量】的方法
 */
function sunDay(a, b, c, d, e, f, g, j, k, n) {
	/*isNan: 不是数字*/
	if(isNaN(a)){
		a = 0;
	}
	if(isNaN(b)){
		b = 0;
	}
	if(isNaN(c)){
		c = 0;
	}
	if(isNaN(d)){
		d = 0;
	}
	if(isNaN(e)){
		e = 0;
	}
	if(isNaN(f)){
		f = 0;
	}
	if(isNaN(g)){
		g = 0;
	}
	if(isNaN(j)){
		j = 0;
	}
	if(isNaN(k)){
		k = 0;
	}
	if(isNaN(n)){
		n = 0;
	}
	
	return a*1 + b*1+ c*1 + d*1 + e*1 + f*1 + g*1 + j*1 + k*1 + n*1;
}

/*
 * 计算【总手续费】的方法
 * 总数量 * 单笔手续费
 */

function sunHand(a,b,c){
	
	if(isNaN(a)){
		a = 0;
	}
	if(isNaN(b)){
		b = 0;
	}
	return (a*1) * (b*1) ;
}


/*
 * 代购手续费总额 = 【总支付金额】
 * 超级链接进入总数量*单笔手续费 +搜索结果进入总数量*单笔手续费
 */
function proceNum(a,b,c,d){
	if(isNaN(a)){
		a = 0;
	}
	if(isNaN(b)){
		b = 0;
	}
	if(isNaN(c)){
		c = 0;
	}
	if(isNaN(d)){
		d = 0;
	}
	if($('#rdocM').is(':checked')){
		return (a*6.5 + b*6.5) ;
	}else if($('#rdocD').is(':checked')){
		return (a*3.7 + b*3.7) ;
	}else{
		return (a*9.6 + b*9.6) ;
	}
}


